package com.xjrsoft.module.visual.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.visual.dto.VisualReleaseListDto;
import com.xjrsoft.module.visual.dto.KbFeaManageDto;
import com.xjrsoft.module.visual.entity.XjrKbFeaManage;
import com.xjrsoft.module.visual.mapper.XjrKbFeamanageMapper;
import com.xjrsoft.module.visual.service.IXjrKbFeaManageService;
import com.xjrsoft.module.visual.vo.KbFeaManageVo;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 看板发布表 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2020-11-18
 */
@Service
public class XjrKbFeamanageServiceImpl extends ServiceImpl<XjrKbFeamanageMapper, XjrKbFeaManage> implements IXjrKbFeaManageService {

    /**
     * @Author:湘北智造-框架开发组
     * @Date:2020/11/19
     * @Param:[dto]
     * @return:com.xjrsoft.common.page.PageOutput
     * @Description:分页查询
     */
    @Override
    public PageOutput selectPageList(VisualReleaseListDto dto) {
        QueryWrapper<XjrKbFeaManage> query = new QueryWrapper<>();
        query.lambda().like(!StrUtil.hasBlank(dto.getKeyword()), XjrKbFeaManage::getFullName, dto.getKeyword());
        IPage<XjrKbFeaManage> kbFeaManageIPage = baseMapper.selectPage(ConventPage.getPage(dto), query);
        return ConventPage.getPageOutput(kbFeaManageIPage, KbFeaManageVo.class);
    }

    /**
     * @Author:湘北智造-框架开发组
     * @Date:2020/12/19
     * @Param:[dto]
     * @return:boolean
     * @Description:更新看板发布
     */
    @Override
    public boolean updateKbFeaManage(String id, KbFeaManageDto dto) {
        XjrKbFeaManage xjrKbFeamanage = BeanUtil.copy(dto, XjrKbFeaManage.class);
        xjrKbFeamanage.setId(id);
        return baseMapper.updateById(xjrKbFeamanage) > 0;
    }
}
